'''
Created on Nov 27, 2010

@author: philip
'''
from django.db import models

class Event(models.Model):
    title = models.CharField(max_length=50)
    description = models.TextField()
    startDate = models.DateTimeField()
    endDate = models.DateTimeField()
    place = models.CharField(max_length=50)
    communityId = models.CharField(max_length=50)
    
    def getPrettyStartDate(self):
        return self.startDate.strftime("%d %B")
    prettyStartDate = property(getPrettyStartDate)
    
    def getPrettyEndDate(self):
        return self.endDate.strftime("%d %B")
    prettyEndDate = property(getPrettyEndDate)
    
    @staticmethod
    def toJSON(e):
        return {"id":e.id,"title":e.title,
                "description":e.description,
                "dateStart":e.startDate.strftime("%d %m"),"dateEnd":e.endDate.strftime("%d %m"),
                "place":e.place
                }